services:
  notifications-service:
    container_name: 'boticord-notifications'
    hostname: 'notifications-service'
    networks:
      - boticord-network
    restart: unless-stopped
    depends_on:
      - postgres
      - nats
      - redis
    environment:
      - BOTICORD_SERVICE=notifications
    env_file:
      - .env
    build:
      context: .
      dockerfile: Dockerfile
      target: notifications

  mysql:
    container_name: 'mysql'
    restart: on-failure
    networks:
      - boticord-network
    env_file:
      - .env
    image: mysql
  migrator:
    container_name: 'migrator'
    restart: no
    networks:
      - boticord-network
    depends_on:
      - postgres
      - mysql
    env_file:
      - .env
    image: boticord/migrator-service:latest
    build:
      context: .
      dockerfile: Dockerfile
      target: migrator

  resources-service:
    container_name: 'boticord-resources'
    hostname: 'resources-service'
    networks:
      - boticord-network
    restart: on-failure
    depends_on:
      - postgres
      - nats
      - redis
    environment:
      - BOTICORD_SERVICE=resources
    env_file:
      - .env
    build:
      context: .
      dockerfile: Dockerfile
      target: resources

  search-service:
    container_name: 'boticord-search'
    hostname: 'search-service'
    networks:
      - boticord-network
    restart: on-failure
    depends_on:
      - meili
    environment:
      - BOTICORD_SERVICE=search
    env_file:
      - .env
    build:
      context: .
      dockerfile: Dockerfile
      target: search

  bot-service:
    container_name: 'boticord-bot'
    hostname: 'bot-service'
    networks:
      - boticord-network
    restart: on-failure
    depends_on:
      - postgres
      - nats
      - redis
    environment:
      - BOTICORD_SERVICE=bot
    env_file:
      - .env
    build:
      dockerfile: Dockerfile
      context: .
      target: bot

  cdn-service:
    container_name: 'boticord-cdn'
    hostname: 'cdn-service'
    networks:
      - boticord-network
    restart: on-failure
    depends_on:
      - postgres
      - nats
      - redis
    environment:
      - BOTICORD_SERVICE=cdn
    env_file:
      - .env
    build:
      dockerfile: Dockerfile
      context: .
      target: cdn

  users-service:
    container_name: 'boticord-users'
    hostname: 'users-service'
    networks:
      - boticord-network
    restart: on-failure
    depends_on:
      - postgres
      - nats
      - redis
    environment:
      - BOTICORD_SERVICE=users
    env_file:
      - .env
    build:
      dockerfile: Dockerfile
      context: .
      target: users

  nginx:
    container_name: 'boticord-nginx'
    hostname: 'nginx'
    networks:
      - boticord-network
    restart: on-failure
    image: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/templates/nginx.conf.template
    ports:
      - '127.0.0.1:80:80'
    environment:
      NGINX_ENVSUBST_OUTPUT_DIR: /etc/nginx
    env_file:
      - ./.env

  nats:
    container_name: 'boticord-nats'
    hostname: 'nats'
    networks:
      - boticord-network
    restart: on-failure
    image: nats

  meili:
    container_name: 'boticord-meili'
    hostname: 'meili'
    networks:
      - boticord-network
    restart: on-failure
    image: 'getmeili/meilisearch:v1.1.1'
    volumes:
      - meili:/meili_data
    env_file:
      - ./.env

  adminer:
    container_name: 'boticord-adminer'
    hostname: 'adminer'
    networks:
      - boticord-network
    restart: on-failure
    image: adminer

  redis:
    container_name: 'boticord-redis'
    hostname: 'redis'
    networks:
      - boticord-network
    restart: on-failure
    image: redis
    command: --save 60 10
    volumes:
      - redis:/data

  postgres:
    container_name: 'boticord-postgres'
    hostname: 'postgres'
    networks:
      - boticord-network
    restart: on-failure
    image: postgres:14
    env_file:
      - ./.env
    volumes:
      - postgres:/var/lib/postgresql/data

volumes:
  postgres:
  meili:
  redis:

networks:
  boticord-network:
